﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Common;
using MyWeb.Business;

namespace MyWeb.Module.Search
{
    public partial class Ketquasp : System.Web.UI.Page
    {
        string Name = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.RouteData.Values["Name"] != null)
            {
                Name = Page.RouteData.Values["Name"].ToString();
            }
            if (!IsPostBack)
            {
                List<Data.Product> list1 = ProductService.Product_GetByTop("100000", "Keyword like '" + Name + "%' ", "");
                ltrPro.Text += "<div class=\"bodyboxpro\"> \n";
                for (int j = 0; j < list1.Count; j++)
                {
                    ltrPro.Text += "  <div class=\"prohome grid\"> \n";
                    ltrPro.Text += "<div class=\"div_img\"> \n";
                    ltrPro.Text += " <a class=\"tooltip\" href=\"/Pro/" + list1[j].GroupId + "/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\"><img src=\"" + list1[j].Image + "\" alt=\"" + list1[j].Name + "\"></a>";
                    ltrPro.Text += "</div>  \n";
                    ltrPro.Text += "<a class=\"productname tooltip\" href=\"/Product/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\">" + list1[j].Name + "</a> \n";
                    ltrPro.Text += "<div class=\"price\"><div class=\"gia\"><span>Giá bán:</span>" + Formatmoney(list1[j].PriceNew) + "</div></div> \n";
                    ltrPro.Text += "<div class=\"dathang\">";
                    ltrPro.Text += "<div class=\"order\"><a href=\"/Shop/" + list1[j].Id + ".aspx\" title=\"\">Đặt mua</a></div> \n";
                    ltrPro.Text += "<div class=\"detail\"><a href=\"/Product/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\"title=\"\">Chi tiết</a></div> \n";
                    ltrPro.Text += "</div>  \n";

                    ltrPro.Text += "<pre class=\"hidden\"><div class=\"boxpro\">  \n";
                    ltrPro.Text += "<div class=\"proname\">" + list1[j].Name + "</div> \n";
                    ltrPro.Text += "<div class=\"proimg1\"><a href=\"\"><img src=\"" + list1[j].Image + "\" align=\"center\"></a></div> \n";
                    ltrPro.Text += "<div class=\"clear\"></div><div class=\"contentpro\"></div><div class=\"teaser\"></div> \n";
                    ltrPro.Text += "</div></pre> \n";
                    ltrPro.Text += "</div> \n";
                }
                ltrPro.Text += "<div class=\"clear\"></div> \n";
                ltrPro.Text += "</div>";

            }
        }
        protected string Formatmoney(string money)
        {
            string tien = "";
            try
            {
                tien = "" + Double.Parse(money).ToString("#,000") + " VNĐ";
            }
            catch
            {
                return tien = "";
            }
            return tien;
        }
    }
}